﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DevExpress.XtraGrid.Localization;

namespace  fuzhu
{
    public class MyGridLocalizer : GridLocalizer
    {
        Dictionary<GridStringId, string> CusLocalizedKeyValue = null;

        public MyGridLocalizer(Dictionary<GridStringId, string> cusLocalizedKeyValues)
        {
            this.CusLocalizedKeyValue = cusLocalizedKeyValues;
        }

        public override string GetLocalizedString(GridStringId id)
        {
            if (CusLocalizedKeyValue != null)
            {
                string gridStringDisplay = string.Empty;
                foreach (var gridLocalizer in CusLocalizedKeyValue)
                {
                    if (gridLocalizer.Key.Equals(id))
                    {
                        gridStringDisplay = gridLocalizer.Value;
                        break;
                    }
                }

                return gridStringDisplay;
            }
            return base.GetLocalizedString(id);
        }

        public Dictionary<GridStringId, string> SetGridLocalizer()
        {
            Dictionary<GridStringId, string> LocalizedKeyValue = new Dictionary<GridStringId, string>();
            LocalizedKeyValue.Add(GridStringId.FindControlFindButton, "查找");
            LocalizedKeyValue.Add(GridStringId.FindControlClearButton, "清空");
            return LocalizedKeyValue;
        }
    }
}
